package com.imooc.jdkproxy;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

/**
* Created By lijiliang on 2018年7月26日 下午2:09:39
*/
public class TimeHandler implements InvocationHandler {
	private Object target;
	
	
	public TimeHandler(Object target) {
		super();
		this.target = target;
	}

	/*
	 * 
	 */
	@Override
	public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
		long starttime=System.currentTimeMillis();
		System.out.println("汽车开始行驶。。");
		System.out.println("日志开始。。");
		method.invoke(target);
		System.out.println("日志结束。。");
		long endtime=System.currentTimeMillis();
		System.out.println("汽车行驶结束。。"+"行驶时间为："+(endtime-starttime)+"毫秒");

		return null;
	}

}
